
{extend name='public/window' /}

{block name="content"}
<style>
    .layui-upload-drag {
        position: relative;
        padding: 10px;
        border: 1px dashed #e2e2e2;
        background-color: #fff;
        text-align: center;
        cursor: pointer;
        color: #999;
        border-radius: 50%;
    }
	.layui-form-label{
		width: 110px;
	}
	.layui-input-block{
		width: 85%;
		margin-left: 146px;
	}
	.layui-input, .layui-textarea {
	    display: block;
	    width: 80%;
	    padding-left: 10px;
	}
	/* .layui-form-select {
	    position: absolute;
	    right: 165px;
	    top: 50%;
		} */
	.layui-form-select .layui-edge {
	    position: absolute;
	    right: 170px !important;
	    top: 50%;
		}
	.layui-form-select dl {
			min-width: 80% !important;
		}
	.layui-form-label {
		    width: 116px !important;
		}
</style>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body" style="padding: 15px;">
            <form class="layui-form" action="" lay-filter="form">
                {if isset($info.id)}
                <input type="hidden" name="id" value="{$info.id}">
                {/if}
                <input type="hidden" name="__token__" id="token" value="{:token()}"/>
                <div class="layui-form-item">
                    <label class="layui-form-label">商户类型* </label>
                    <div class="layui-input-block" >
                        <select name="type"  lay-filter="type" id="type_select">
                            <option value="">请选择</option>
                            <option value="1">写字楼</option>
                            <option value="2">商场零售</option>
                            <option value="3">商场非零</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item nolins" >
                    <label class="layui-form-label">商户编号* </label>
                    <div class="layui-input-block">
                        <input type="text" name="merchant_sn" lay-verify="required"  autocomplete="off"
                               placeholder="请输入商户编号" class="layui-input" id="merchant_sn_edit">
                    </div>
                </div>
             <!--   <div class="layui-form-item">
                    <label class="layui-form-label">房间号 *</label>
                    <div class="layui-input-block">
                        <input type="text" name="room_id" lay-verify="required" autocomplete="off"
                               placeholder="请输入品牌名称" class="layui-input" id="room_id">
                    </div>
                </div> -->
                <div class="layui-form-item nolins">
                    <label class="layui-form-label">品牌名称 </label>
                    <div class="layui-input-block">
                        <input type="text" name="name"  autocomplete="off"
                               placeholder="请输入品牌名称" class="layui-input" id="name_edit">
                    </div>
                </div>
                <div class="layui-form-item nolins">
                    <label class="layui-form-label">公司名称 </label>
                    <div class="layui-input-block">
                        <input type="text" name="company"  autocomplete="off"
                               placeholder="请输入公司名称" class="layui-input" id="company_edit">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">组织 </label>
                    <div class="layui-input-block" >
                        <select id="organization" name="organization" lay-search="" lay-filter="organization">
                            <option value="">请选择</option>
                            {volist name="orange" id="v"}
                            <option value="{$v.id}">{$v.name}</option>
                            {/volist}
                        </select>
                        {if !empty($info.organization_one)}
                        <div id="show">
                            <select id="organization_one"  name="organization_one" >
                                <option value="">请选择</option>
                                {volist name="orange_one" id="v"}
                                <option value="{$v.id}">{$v.name}</option>
                                {/volist}
                            </select>
                        </div>
                            {else/}
                         <div id="show" style="display:none">
                            <select id="organization_one"  name="organization_one" >
                                <option value="">请选择</option>
                            </select>
                        </div>
                        {/if}

                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">所属楼层* </label>
                    <div class="layui-input-block" >
                        <select name="lcName"  lay-filter="lcName" id="lcName">
                            <option value="">请选择</option>
                            {volist name="lc" id="v1"}
                            <option value="{$v1.lcName}">{$v1.lcName}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">业态* </label>
                    <div class="layui-input-block" >
                        <select name="activities"  lay-filter="activities" id="activities">
                            <option value="">请选择</option>
                            {volist name="activities" id="v1"}
                            <option value="{$v1.name}">{$v1.name}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
                <div class="layui-form">
                    <div class="layui-form-item">
                        <label class="layui-form-label">选择上报任务</label>
                        <div class="layui-input-block">
                            <div id="task_id" style="width:80%"></div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">负责人姓名 * </label>
                    <div class="layui-input-block">
                        <input type="text" name="username" lay-verify="required" placeholder="请输入负责人姓名"
                               class="layui-input" id="username_edit">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">期初余额 * </label>
                    <div class="layui-input-block">
                        <input type="number" name="start_balance"  placeholder="请输入期初余额"
                               class="layui-input" id="start_balance">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">账户余额 * </label>
                    <div class="layui-input-block">
                        <input type="number" name="balance"  placeholder="请输入账户余额"
                               class="layui-input" id="balance">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">手机号码 </label>
                    <div class="layui-input-block">
                        <input type="text" name="mobile"  autocomplete="off" placeholder="请输入手机号码"
                               class="layui-input" id="mobile_edit">
<!--                        <div style="width: 100%;color: #f74e4e;font-size: 15px;padding-top: 5px">如需为商户添加多个管理员，请用“，”分隔每位管理员的手机号即可。如：“13000000000，13000000001，13000000002”</div>-->
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">发票类型* </label>
                    <div class="layui-input-block" >
                        <select name="invoiceType"  lay-filter="type" id="invoiceType">
                            <option value="">请选择</option>
                            <option value="1">普通发票</option>
                            <option value="2">专用发票</option>
                        </select>
                    </div>
                </div>
              <!--  <div class="layui-form-item">
                    <label class="layui-form-label">是否特行用水</label>
                    <div class="layui-input-block" >
                        <input type="radio" name="electricity_type" value="2" title="是" lay-filter="is_tax">
                        <input type="radio" name="electricity_type" value="1" title="否" lay-filter="is_tax" checked>
                    </div>
                </div> -->
                <div class="layui-form-item">
                    <label class="layui-form-label">请输入数采编号 * </label>
                    <div class="layui-input-block">
                        <input type="text" name="UniqueKey"  placeholder="请输入数采编号"
                               class="layui-input" id="UniqueKey">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">是否自动合闸* </label>
                    <div class="layui-input-block" >
                        <select name="is_auto"  lay-filter="type" id="is_auto">
                            <option value="2">是</option>
                            <option value="1">否</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">品牌编号 * </label>
                    <div class="layui-input-block">
                        <input type="text" name="brand_code"  placeholder="品牌编号"
                               class="layui-input" id="brand_code">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">业态名称 * </label>
                    <div class="layui-input-block">
                        <input type="text" name="bizType_name"  placeholder="业态名称"
                               class="layui-input" id="bizType_name">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">业态编号 * </label>
                    <div class="layui-input-block">
                        <input type="text" name="bizType_code"  placeholder="业态编号"
                               class="layui-input" id="bizType_code">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">是否冻结</label>
                    <div class="layui-input-block" >
                        <input type="radio" name="status" value="-1" title="是" lay-filter="is_tax">
                        <input type="radio" name="status" value="1" title="否" lay-filter="is_tax" checked>
                    </div>
                </div>
         <!--       <div class="layui-form-item">
                    <label class="layui-form-label">电费度数上限</label>
                    <div class="layui-input-block">
                        <input type="text" name="number" autocomplete="off" placeholder="请输入交电费最高度数"
                               class="layui-input" id="number_edit">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">入驻时间 *</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" lay-verify="required" name="start_time" id="start_time" placeholder="请选择入驻时间">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">合同到期时间 *</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" lay-verify="required" name="end_time" id="end_time" placeholder="请选择合同到期时间">
                    </div>
                </div> -->
                <div class="layui-form-item layui-layout-admin " style="width: 100%">
                    <div class="layui-input-block">
                        <div class="layui-footer" style="left: 0px;text-align: center;">
                            <button class="layui-btn" lay-submit="" lay-filter="upBalance">更新余额</button>
                            <button class="layui-btn" lay-submit="" lay-filter="add">{:__('Submit')}</button>
                            <button type="reset" class="layui-btn layui-btn-primary">{:__('Reset')}</button>
                        </div>
                    </div>
                </div>

            </form>
        </div>
    </div>
</div>


<script>
    layui.use(['element', 'form', 'jquery','lucky','upload','laydate','xmSelect'], function () {
        var element = layui.element;
        var table = layui.table;
        var form = layui.form;
        var laydate = layui.laydate;
        var $ = layui.jquery;
        var lucky=layui.lucky;
        var xmSelect = layui.xmSelect;
        var task = {:json_encode($task)};
        var demo = xmSelect.render({
            el:'#task_id',
            data:task
        })
        laydate.render({
            elem: '#start_time'
            ,type: 'date',
            trigger: 'click'
        });
        laydate.render({
            elem: '#end_time'
            ,type: 'date',
            trigger: 'click'
        });
        // form.on('select(type)', function(data){
        //     var  type = data.value;
        //     if(type==2){
        //         $(".nolins").css('display','none'); //隐藏
        //     }else{
        //         $(".nolins").css('display','block');
        //     }
        // });
        // var type = "{$info.type}";
        // if(type==2){
        //     $(".nolins").css('display','none'); //隐藏
        // }
        form.on('select(organization)', function (data) {
            var value = $("#organization").val();
            $("#organization_one").val('');
            form.render("select");
            $.ajax({
                url:"{:url('change')}",
                method:'post',
                data:{
                  pid:value
                },
                success:function (res){
                    var info = res.data;
                    if(info.length!=0){
                    info.forEach((elem, index) => {
                            $("#organization_one").append('<option value='+elem['id']+">"+elem['name']+'</option>');
                        });
                        //重新渲染
                        layui.form.render("select");
                        $('#show').show();
                    }else {
                        $('#show').hide()
                    }
                }
            })
        });
        //表单赋值
        var info = {:json_encode($info)};
        form.val("form",info);
        form.on('submit(add)', function (data) {
            lucky.FormSubmit("{:url('add')}",data.field,true);
            return false;
        });
        form.on('submit(upBalance)', function (data) {
            console.log(data)
            lucky.FormSubmit("{:url('upBalance')}",data.field,true);
            return false;
        });
    })
</script>

{/block}

